<!--
 * @FileDescription 工具栏
 * @Author lz
 * @Date 20230224 18:19:38
 * @LastEditors lz
 * @LastEditTime 20230224 18:19:38
-->
<template>
    <div class="toolbar_wp" v-if="state.show">
        <div class="tit">工具栏</div>
        <img src="/structure/DecorativeLine_r.png" class="line">
        <img src="/structure/develop.png" class="develop" @click="show()">
        <div class="toolbar_content">
            <div class="toolbarName">
                {{ HomeContent.Default.ToolInformation.value.Name }}
            </div>
            <img :src="HomeContent.Default.Tool_Icon.value" class="strumento_ico"
                v-if="HomeContent.Default.ToolInformation.value.Icon">
            <div class="ToggleBar" v-if="HomeContent.Default.ToolInformation.value.Setting">
                <img src="/structure/gjl_l_arr.png" class="togBtn" @click="sub()">
                <div class="numVal">
                    <a-input-number id="inputNumber" v-model:value="HomeContent.Default.ToolInformation.value.Value"
                        :min="HomeContent.Default.ToolInformation.value.Min"
                        :max="HomeContent.Default.ToolInformation.value.Max"
                        :step="HomeContent.Default.ToolInformation.value.increment" />
                </div>
                <img src="/structure/gjl_r_arr.png" class="togBtn" @click="add()">
            </div>
        </div>
        <div class="retrieve" @click="retrieveBtn()" v-if="HomeContent.Default.ToolInformation.value.Icon">
            <img src="/structure/retrieve.png" class="retrieve_ico">
            放回
        </div>
    </div>
    <div class="StowedState" v-if="!state.show" @click="show()">
        <img src="/structure/ExpandArrow_r.png" class="expArr">
    </div>
</template>

<script setup lang="ts">
import { ClientMessage } from '@runtime/generate/message/ClientMessage';
import WebSocketComponent from '@runtime/module/WebSocket/WebSocketComponent';
import { reactive, ref, watch } from 'vue';
import HomeContent from '../../HomeContent';
import MessageCode from '../../MessageCode';
const state = reactive({
    show: true,
});
function show() {
    state.show = !state.show
}
function add() {
    if (HomeContent.Default.ToolInformation.value.Value < HomeContent.Default.ToolInformation.value.Max) {
        HomeContent.Default.ToolInformation.value.Value += HomeContent.Default.ToolInformation.value.increment
    }
}
function sub() {
    if (HomeContent.Default.ToolInformation.value.Value > HomeContent.Default.ToolInformation.value.Min) {
        HomeContent.Default.ToolInformation.value.Value -= HomeContent.Default.ToolInformation.value.increment
    }
}
//放回
function retrieveBtn(){
    WebSocketComponent.Default.PostMessageAsync(new ClientMessage.DisassemblyAdapterRequest(MessageCode.Default.MsgCodesList.TOOL_BAR_PUTBACK))
}
//监听工具栏数值
watch(() => HomeContent.Default.ToolInformation.value.Value, (newVal, oldVal) => {
    if (newVal != oldVal) {
        WebSocketComponent.Default.PostMessageAsync(new ClientMessage.DisassemblyAdapterRequest(MessageCode.Default.MsgCodesList.TOOL_BAR_ARGUMENT, HomeContent.Default.ToolInformation.value.Value.toString()))
    }
})
</script>

<style scoped>
.toolbar_wp {
    position: absolute;
    top: 745px;
    right: 0;
    width: 290px;
    height: 303px;
    background-image: url('/structure/cz_gjl_bg.png');
    background-repeat: no-repeat;
    background-size: 100% 100%;
}

.StowedState {
    position: absolute;
    right: 0;
    top: 752px;
    width: 52px;
    height: 52px;
    background-image: url('/structure/stowedState_r_bg.png');
    background-repeat: no-repeat;
    background-size: 100% 100%;
}

.expArr {
    width: 27px;
    height: 32px;
    margin-top: 10px;
    margin-left: 13px;
}

.line {
    width: 272px;
    height: 28px;
    position: absolute;
    right: 8px;
    top: 32px;
}

.tit {
    text-align: right;
    font-size: 22px;
    font-family: YouSheBiaoTiHei;
    font-weight: 400;
    color: #ffffff;
    padding-right: 38px;
    padding-top: 12px;
    margin-bottom: 26px;
}

.develop {
    position: absolute;
    left: 4px;
    top: 14px;
    width: 27px;
    height: 32px;
}

.toolbarName {
    font-size: 18px;
    font-weight: bold;
    color: #FFFFFF;
}

.toolbar_content {
    text-align: center;
}

.ToggleBar {
    display: flex;
    justify-content: center;
    align-items: center;
    position: absolute;
    bottom: -8px;
    left: 60px;
}

.togBtn {
    width: 24px;
    height: 24px;
}

.numVal {
    width: 96px;
    height: 49px;
    background-image: url('/structure/cz_jf_btn_bg.png');
    background-repeat: no-repeat;
    background-size: 100% 100%;
    margin: 20px 12px;
    line-height: 49px;
    font-size: 16px;
    font-weight: 400;
    color: #B1D0F4;
}

:deep().ant-input-number {
    background: transparent;
    border: none;
    box-shadow: none;
}

:deep().ant-input-number-handler-wrap {
    display: none;
}

:deep().ant-input-number-input {
    text-align: center;
    color: #fff;
}

.strumento_ico {
    width: 160px;
    height: 160px;
    margin-top: -10px;
}
.retrieve {
    font-size: 16px;
    font-family: Microsoft YaHei;
    font-weight: bold;
    color: #00E7FF;
    position: absolute;
    bottom: 6px;
    right: 4px;
}
.retrieve_ico {
    width: 20px;
    height: 20px;
    margin-top: -3px;
}

</style>